import { h, ref, unref, reactive } from 'vue'
import { findDictBrand,findDictTypeList} from '@/api/common'
import { dictType,mountStatusType} from '@/utils/dict'
import { dataToSelect} from '@/utils'
import { Edit} from '@element-plus/icons-vue'
import { airportList } from '@/api/resource-manage'


let router:any = null

/**
 *  获取路由对象
 */
export function getRouterInstance(r) {
  router = r
}

let DT:any = null


// 品牌
const airportBrand = ref<dictType[]>([]) 
// 无人机型号
const airportModelCode = ref<dictType[]>([]) 
// 无人机状态
const airportStatus = ref<dictType[]>([]) 


// 获取data对象
export function getDataInstance(data) {
  DT = data
}

interface optionsType{
  label:string
  value:string | number | null | undefined
}
interface formItemType {
  type: string,
  key: string,
  label: string,
  row: object,
  props: object
  options?: optionsType[]
}

interface OnionsType {
  modalForm:any
  formItem: formItemType[]
  modalRules?:object
}

// 基础信息
export const baseOpions = reactive({
  modalForm: {
    fileList:[],
    fileUrl:null, // 航线地址
    name:null, // 航线名称
    airportId:null, // 机场id
    note:null, // 航线描述
    length:999, // 航线长度
  },
  formItem: [
    {
      type: 'upload',
      key: 'fileList',
      label: '航线地址',
      row: { sm: 24, md: 24 },
      props: { maxlength: '50', clearable: true, placeholder: '请上传航线地址' }
    },
    {
      type: 'input',
      key: 'name',
      label: '航线名称',
      row: { sm: 24, md: 24},
      props: { clearable: true, placeholder: '请输入' }
    },
    {
      type: 'select',
      key: 'airportId',
      label: '关联机场',
      options: [],
      row: { sm: 24, md: 24},
      props: { clearable: true, placeholder: '请选择' }
    },
    {
      type: 'input',
      key: 'note',
      label: '航线描述',
      row: { sm: 24, md: 24 },
      props: { clearable: true, placeholder: '请输入',type: 'textarea'}
    },
  ],
  modalRules: {
    fileList: [{  type: 'array',required: true, message: '请上传航线地址', trigger: ['change'] }],
    name: [{ required: true, message: '请输入', trigger: ['change'] }],
    airportId: [{ required: true, message: '请选择', trigger: ['change'] }],
    note: [{ required: true, message: '请输入', trigger: ['change'] }],
  },
})

// 机场 字典数据类型
export const getAirportList = async function () {
  const {data} = await  airportList({}) as any

}